<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2><if condition="ACTION_NAME eq 'add'">新建<else/>编辑</if>预约单</h2>
    </div>

    <form action="{:U()}" id="commentForm" method="post"  class="form-horizontal" >
    <!-- 判断插入ID是否为空，如不为空隐藏插入ID值 -->
        <notempty name="data['id']">
            <input type="hidden" name="id" value="{$data['id']}"/>
        </notempty>
            <input type="hidden" name="p" value="<?php echo $_GET['p']; ?>"/>
		<div class="form-item">
            <label class="item-label">顾客标签<span class="check-tips"></span></label>
            <div class="controls">
                <select name="gkbq">
                      <volist name="gkbq" id="vo">     
                            <option value="{$vo.uid|default=null}" <eq name="vo.uid" value="$data.gkbq"> selected</eq>>{$vo.name|default=null}</option>
                      </volist>
                </select>
            </div>
        </div>	
        <div class="form-item">
            <label class="item-label">顾客姓名<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="name" value="{$data.name}" >
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">顾客手机号码<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="phone" value="{$data.phone}" >
            </div>
        </div>
		<div class="form-item">
            <label class="item-label">顾客微信<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="qq" value="{$data.qq}" >
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">旺旺<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="wangwang" value="{$data.wangwang}" >
            </div>
        </div>
		<div class="form-item">
            <label class="item-label">微博<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="weibo" value="{$data.weibo}" >
            </div>
        </div>
		<neq name="quanxian" value="4"> 
        <div class="form-item">
            <label class="item-label">预约日期<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" placeholder="请输入日期" class="text input-large laydate-icon" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm'})" name="yytime"  <if condition="ACTION_NAME eq 'add'"> <else /> <neq name="data['yytime']" value="0">  value="{$data.yytime|time_format}"</neq> </if>style="padding-right: 3px;">
        </div>
		</neq>
        <div class="form-item">
            <label class="item-label">线上备注<span class="check-tips">（请线上门市填写备注）</span></label>
            <div class="controls">
                <textarea  class="text input-large" style="height: 100px;" name="bz" value="{$data.bz}">{$data.bz}</textarea>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">线下备注<span class="check-tips">（请线下门市填写备注）</span></label>
            <div class="controls">
                <textarea  class="text input-large" style="height: 100px;" name="xxbz" value="{$data.xxbz}">{$data.xxbz}</textarea>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">获取客服<span class="check-tips"></span></label>
            <div class="controls">
                <select name="kf" {$kfqx}{$huoqu}>
							<php>if(count($kefu) !== 1){echo "<option value=''>未分配门市</option>";}</php>
                      <volist name="kefu" id="vo">
                            <option value="{$vo.uid|default=null}" <eq name="vo.uid" value="$data.kf"> selected</eq>>{$vo.nickname|default=null}</option>
                      </volist>
                </select>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">渠道<span class="check-tips"></span></label>
            <div class="controls">
                <select name="qd" {$xsqx} id="qudao">
                      <volist name="qudao" id="vo">     
                            <option value="{$vo.uid|default=null}" <eq name="vo.uid" value="$data.qd"> selected</eq>>{$vo.name|default=null}</option>
                      </volist>
                </select>
            </div>
        </div>
		<div class="form-item">
            <label class="item-label">来源信息<span class="check-tips">(例：如果渠道是百度可以输入搜索关键词）</span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="qdly" value="{$data.qdly}" >
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">业务类别<span class="check-tips"></span></label>
            <div class="controls">
                <select name="lb" {$xsqx}>
                    <volist name="liebei" id="vo" >
                        <option value="{$vo.uid|default=null}" <eq name="vo.uid" value="$data.lb"> selected</eq>>{$vo.name|default=null}</option>
                    </volist>
                </select>
            </div>
        </div>    
		<div class="form-item">
            <label class="item-label">挖潜部门<span class="check-tips"></span></label>
            <div class="controls">
	
                <select name="wqbm" id="wqbm" >
						<option value=''>请选择部门</option>
                    <volist name="wqbm" id="vo" >
                        <option value="{$vo.id|default=null}" <eq name="vo.id" value="$data.wqbm"> selected</eq>>{$vo.title|default=null}</option>
                    </volist>
                </select>
            </div>
        </div>  
		<div class="form-item">
            <label class="item-label">挖潜人员<span class="check-tips"></span></label>
            <div class="controls">
                <select name="wqry" id="wqry" >
					<option value=''>请选择人员</option>
                    <volist name="wqry" id="vo" >
                        <option value="{$vo.id|default=null}" <eq name="vo.id" value="$data.wqry"> selected</eq>>{$vo.title|default=null}</option>
                    </volist>
                </select>
            </div>
        </div>  
<!--        	<div class="form-item">
                <label class="item-label">挖潜人</label>
                <div class="controls">
                    <input type="text" class="text input-large" name="waqianren" value="{$data.waqianren}">
                </div>
        </div> -->
            <div class="form-item">
                <label class="item-label">线上门市<span class="check-tips">(选择“线上门市”后系统会发送微信通知信息到指定门市）</span></label>
                <div class="controls">
                      <!-- <select name="xsjd" {$xsjl}> -->
                      <select name="xsjd" >
                            <php>if(count($xianshang) !== 1){echo "<option value=''>未分配门市</option>";}</php>
                            <volist name="xianshang" id="vo">
                                <option value="{$vo.uid|default=null}" <php>if($vo['uid'] === $data['xsjd']){echo "selected";
                                }</php> >{$vo.nickname|default=null}</option>                          
                            </volist>
                      </select>
                </div>
            </div>
         <neq name="quanxian" value="4">    
            <div class="form-item">
                <label class="item-label">线下门市<span class="check-tips"></span></label>
                <div class="controls">
                      <select name="xxjd" {$xxjl}>
                            <php>if(count($xianxia) !== 1){echo "<option value=''>未分配门市</option>";}</php>
                            <volist name="xianxia" id="vo">
                                <option value="{$vo.uid|default=null}" <php>if($vo['uid'] === $data['xxjd']){echo "selected";
                                }</php> >{$vo.nickname|default=null}</option>                          
                            </volist>
                      </select>
                </div>
            </div>

            <div class="form-item">
                <label class="item-label">套系价格<span class="check-tips">（请填写套系价格）</span></label>
                <div class="controls">
                    <input type="text" class="text input-large" name="setmoney" value="{$data.setmoney}">
                </div>
            </div>
            <div class="form-item">
                <label class="item-label">实收金额<span class="check-tips">（请填写实收金额）</span></label>
                <div class="controls">
                    <input type="text" class="text input-large" name="money" value="{$data.money}">
                </div>
            </div>
			<div class="form-item">
                <label class="item-label">支付款项<span class="check-tips"></span></label>
                <div class="controls">
			<select name="zfkx">
					<option value="">无</option>
				<volist name="zfkx" id="vo">
					<option value="{$vo.uid|default=null}" <eq name="vo.uid" value="$data.zfkx"> selected</eq>>{$vo.name|default=null}</option>
				</volist>
			</select>
                </div>
            </div>
			<div class="form-item">
                <label class="item-label">支付方式<span class="check-tips"></span></label>
                <div class="controls">
			<select name="zffs">
					<option value="">无</option>
				<volist name="zffs" id="vo">
					<option value="{$vo.uid|default=null}" <eq name="vo.uid" value="$data.zffs"> selected</eq>>{$vo.name|default=null}</option>
				</volist>
			</select>
                </div>
            </div>
			<div class="form-item">
                <label class="item-label">排档时间<span class="check-tips">（如拍档时间只有1天，只填写开始时间，若果多天需要填写结束时间）</span></label>
                <div class="controls">
                     <input type="text" placeholder="请输入拍档开始时间" class="text laydate-icon" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})" name="pdtimes"  <if condition="ACTION_NAME eq 'add'">  <else /> <neq name="data['pdtimes']" value="0">value="{$data.pdtimes|date="Y-m-d",###}" </neq></if> >
					  - 
					 <input type="text" placeholder="请输入拍档结束时间" class="text laydate-icon" onclick="laydate({istime: true, format: 'YYYY-MM-DD'})" name="pdtimee"  <if condition="ACTION_NAME eq 'add'">  <else /> <neq name="data['pdtimee']" value="0">value="{$data.pdtimee|date="Y-m-d",###}" </neq></if> >
                </div>
			
            </div>
        </neq>
        <div class="form-item">
            <label class="item-label">订单状态<span class="check-tips"></span></label>
            <div class="controls">
                <select name="ywstate">
                    <volist name="state" id="vo">
                        <option value="{$vo.uid|default=null}" <eq name="vo.uid" value="$data.ywstate"> selected</eq>>{$vo.name|default=null}</option>
                    </volist>
                </select>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">线下服务时间<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" placeholder="请输入日期" class="text input-large laydate-icon" onclick="laydate({istime: true, format: 'YYYY-MM-DD hh:mm'})" name="xxfwtime"  <if condition="ACTION_NAME eq 'add'"> <else /> <neq name="data['xxfwtime']" value="0">  value="{$data.xxfwtime|time_format}"</neq> </if> style="padding-right: 3px;">
        </div>		
        <div class="form-item">
            <label class="item-label">推荐人<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="tj" value="{$data.tj}">
            </div>
        </div>   

        <div class="form-item">
            <button class="btn submit-btn" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>
<div id="AjaxLoading" class="showbox">
    <div class="loadingWord"><img src="__IMG__/waiting.gif">数据提交中，请稍候...</div>
</div>

   
</block>

<block name="script">
    <script src="__STATIC__/thinkbox/jquery.validate.js"></script>
    <script src="__STATIC__/thinkbox/jquery.metadata.js"></script>
    <script src="__STATIC__/thinkbox/laydate.js"></script>
     <script type="text/javascript">
$(document).ready(function(){
    


            var qudao      = $('#qudao');
            var wqbm       = $('#wqbm');
            var wqry       = $('#wqry');
            qudao.change(function(){
				var id = $(this).val();
				if(id == 177){
					wqbm.removeAttr("disabled");
					wqry.removeAttr("disabled");
				}else{
					wqbm.attr("disabled", true); 
					wqry.attr("disabled", true); 
				}
            });
            wqbm.change(function(){
                if($(this).val() == ''){
                    wqry.empty();
                    $("<option value=''>"+'请选择挖潜人员'+"</optinon>").appendTo(wqry);
                }else{
                    wqry.empty();
                    $("<option value=''>"+'请选择挖潜人员'+"</optinon>").appendTo(wqry);
                    $.post("{:U('waqian/waqianrenyuan')}", { id:$(this).val()},function(data){
                        $.each(eval(data),function(i,n){
                            $("<option value='"+n.id+"'>"+n.title+"</optinon>").appendTo(wqry);
                        });
                    });
                }
            });
         
        $("#phone").blur(function(){
            $.post("/admin/yewu/getjinpaiphone.html", {phone:$("#phone").val(),id:$("#id").val()},function(vo){
                if(vo.status == 0){
                    layer.msg(vo.msg, {icon: vo.icon});
                    $('#submit').attr("disabled","false"); //禁止点击
                }else{
                    $('#submit').removeAttr("disabled"); //打开点击
                }
            });
        });
        $("#qq").blur(function(){
            $.post("/admin/yewu/getqq.html", {qq:$("#qq").val(),id:$("#id").val()},function(vo){
                if(vo.status == 0){
                    layer.msg(vo.msg, {icon: vo.icon});
                    $('#submit').attr("disabled","false"); //禁止点击
                }else{
                    $('#submit').removeAttr("disabled"); //打开点击
                }
            });  
        });

    
    
    $(".action").click(function(){
    
        
        
    });
    
});
</script>
    <script >

    $().ready(function() {
         $("#commentForm").validate({

          rules: {
           name: { required:true
           },
           phone: {
            //isMobile : true
           },
           yytime:{
            dataTime:true
           },
		   pdtimes:{
            date:true
           },
		   pdtimee:{
            date:true
           }
		   
		   
          },
           messages: {
               name: "请输入姓名！",
               phone: {
                required: "请输入手机号码！",
                isMobile: "请输入正确的手机号码！"
               },
               yytime:{
                dataTime:"请填写正确预约时间！"
               },
			   pdtimes:{
                date:"请填写正确拍档时间！"
               },
			   pdtimee:{
                date:"请填写正确拍档时间！"
               }
			   
            },
            submitHandler : function(form){

            $.ajax({
                type: "POST",
               <if condition="ACTION_NAME eq 'add'">url: "{:U('add')}",<else/>url: "{:U('edit')}",</if> 
                data: $(form).serialize(),
                beforeSend:function(){
                    $(".overlay").css({'display':'block','opacity':'0.8'});
        
                    $(".showbox").stop(true).animate({'margin-top':'300px','opacity':'1'},200);//loanding 打开显示
                    
                },
                success: function(msg){
                    $(".showbox").stop(true).animate({'margin-top':'250px','opacity':'0'},400);
                    $(".overlay").css({'display':'none','opacity':'0'});//loanding 停止显示

                    $('.alert-content').html(msg.info);
                    $('#top-alert').addClass('alert-success').show();
					
                    setTimeout(function(){
                       location.href=msg.url+"#{$data.id}";
                    },3000); //延迟演示
					setTimeout(function(){
                       $('#submit').removeAttr("disabled");
                    },1000); //延迟演示
					setTimeout(function(){
                       $('#top-alert').addClass('alert-success').hide();
                    },2000); //延迟演示
                },
            });

            $('#submit').attr("disabled","false");
            }

         });

          return false;   
        });
    </script>
    <script type="text/javascript">
        //导航高亮
        highlight_subnav('{:U('Ywxt/index')}');
    </script>
</block>
